package com.nika.usercenter.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nika.usercenter.model.domain.User;
import com.baomidou.mybatisplus.extension.service.IService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

import static com.nika.usercenter.constant.UserConstant.USER_LOGIN_STATE;

/**
* @author HT
* @description 针对表【user(用户)】的数据库操作Service
* @createDate 2022-08-09 23:10:27
*/
public interface UserService extends IService<User> {

    /**
     *
     * @param userAccount 账户
     * @param userPassword 密码
     * @param checkPassword 校验码
     * @return 返回新用户id
     */

    long userRegister(String userAccount,String userPassword,String checkPassword);

    /**
     *
      * @param userAccount 账户
     * @param userPassword 密码
     * @param request servletRequest
     * @return User
     */

    User doLoginBySession(String userAccount, String userPassword, HttpServletRequest request);

    /**
     *  通过token实现用户登录
     * @param userAccount 账户
     * @param userPassword 密码
     * @return User
     */

    String doLoginByToken(String userAccount, String userPassword);

    /**
     *
     * @param originUser
     * @return
     */

    User getSafetyUser(User originUser);

    /**
     *
     * @param request
     * @return
     */
    int userLogOut(HttpServletRequest request);

    /**
     * 根据标签搜索用户
     * @param tagNameList
     * @return
     */
    List<User> searchUsersByTags(List<String> tagNameList);

    /**
     * 更新用户 session
     * @param user
     * @param loginUser
     * @return
     */
    int updateUser(User user,User loginUser);

    /**
     * 更新用户 session
     * @param user
     * @param loginUser
     * @return
     */
    int updateUserByToken(User user,User loginUser);



    /**
     * 判断权限
     * @param request
     * @return
     */
    boolean isAdmin(HttpServletRequest request);


    boolean isAdmin(User loginUser);

    User getLoginUser(HttpServletRequest request);

    /**
     * token获取用户
     * @param request
     * @return
     */
    User getLoginUserByToken(HttpServletRequest request);

    /**
     * 给推荐页获取信息
     * @param pageSize
     * @param pageNum
     * @param request
     * @return
     */

    Object getRecommendFromCache(long pageSize,long pageNum,HttpServletRequest request);

    List<User> matchUsers(long num, User loginUser);
}
